<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!-- 检查项目 -->
      <el-col :span="18">
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane
            :label="item.label"
            :name="item.value"
            v-for="(item, index) in projectTypeList"
            :key="index"
          >
          </el-tab-pane>
        </el-tabs>
        <el-row :gutter="20">
          <!-- 检查项目 -->
          <el-col :span="24">
            <el-tabs
              v-model="projectActiveName"
              @tab-click="handleClick"
              tab-position="left"
            >
              <el-tab-pane
                :label="item.label"
                :name="item.value"
                v-for="(item, index) in projectList"
                :key="index"
              >
                <!-- 可编辑表格 -->
                <el-col :span="24">
                  <el-table
                    v-loading="loading"
                    :data="list"
                    highlight-current-row
                  >
                    <el-table-column
                      label="编码名称"
                      align="center"
                      prop="num"
                    />
                    <el-table-column label="原价" align="center" prop="num" />
                    <el-table-column label="应收" align="center" prop="num" />
                    <el-table-column label="序号" align="center" prop="num" />
                    <el-table-column
                      label="支付方式"
                      align="center"
                      prop="num"
                    />
                    <el-table-column label="应收" align="center" prop="num" />
                  </el-table>
                </el-col>
              </el-tab-pane>
            </el-tabs>
          </el-col>
        </el-row>
      </el-col>
      <!-- 常用取值 / 历次结果 -->
      <el-col :span="6">
        <el-tabs v-model="commonActiveName" @tab-click="handleClick">
          <el-tab-pane label="常用取值" name="1">
            <el-table :data="normalCodeList" highlight-current-row>
              <el-table-column label="" align="center" prop="normalCode">
                <template slot="header" slot-scope="scope">
                  <el-input
                    v-model="normalCodeSearch"
                    size="small"
                    placeholder="输入关键字搜索"
                  />
                </template>
                <template slot-scope="scope">
                  {{ scope.row.normalCode }}
                </template>
              </el-table-column>
              <el-table-column align="right">
                <template slot="header" slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    icon="el-icon-plus"
                    @click="handleAdd(scope.$index, scope.row)"
                    >新增</el-button
                  >
                </template>
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    @click="handleEdit(scope.$index, scope.row)"
                    >编辑</el-button
                  >
                  <el-button
                    size="mini"
                    type="text"
                    @click="handleDelete(scope.$index, scope.row)"
                    >删除</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="历次结果" name="2"> </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "TableData",
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 检查项目表格数据
      list: [
        {
          num: 0,
        },
      ],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      // 当前页
      activeName: "1",
      // 检查项目类型
      projectTypeList: [
        {
          label: "体检科",
          value: "1",
        },
        {
          label: "外科",
          value: "2",
        },
        {
          label: "内科",
          value: "3",
        },
        {
          label: "B超室",
          value: "4",
        },
        {
          label: "放射科",
          value: "5",
        },
        {
          label: "心电图室",
          value: "6",
        },
      ],
      // 检查项目
      projectList: [
        {
          label: "[未]体格检查",
          value: "1",
          result: "222",
          range: "12",
        },
        {
          label: "[未]体格检查",
          value: "2",
          result: "222",
          range: "12",
        },
        {
          label: "dsdsa",
          value: "3",
          result: "222",
          range: "12",
        },
      ],
      // 检查项目 tab 栏
      projectActiveName: "1",
      // 常用取值
      normalCodeList: [
        {
          normalCode: "偏大",
          value: "1",
        },
        {
          normalCode: "偏小",
          value: "2",
        },
      ],
      // 常用取值/历次结果 tab 栏
      commonActiveName: "1",
      // 常用取值搜索
      normalCodeSearch: undefined,
    };
  },
  methods: {
    // tab-click
    handleClick() {},
    /** 查询检查项目列表 */
    getList() {
      this.loading = true;
      // listProject(this.queryParams).then((response) => {
      //   this.projectList = response.rows
      //   this.total = response.total
      //   this.loading = false
      // })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        categoryId: null,
        projectName: null,
        price: null,
        description: null,
        sexLimit: 2,
        ageLimit: null,
        address: null,
        isDel: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
      };
      // this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增";
    },
    /** 编辑按钮操作 */
    handleUpdate(row) {
      this.reset();
      // const id = row.id || this.ids
      // getProject(id).then((response) => {
      //   this.form = response.data
      //   this.open = true
      //   this.title = '编辑'
      // })
    },
    /** 提交按钮 */
    submitForm() {
      // this.$refs['form'].validate((valid) => {
      //   if (valid) {
      //     if (this.form.id != null) {
      //       updateProject(this.form).then((response) => {
      //         this.$modal.msgSuccess('编辑成功')
      //         this.open = false
      //         this.getList()
      //       })
      //     } else {
      //       addProject(this.form).then((response) => {
      //         this.$modal.msgSuccess('新增成功')
      //         this.open = false
      //         this.getList()
      //       })
      //     }
      //   }
      // })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      // const ids = row.id || this.ids
      // this.$modal
      //   .confirm('是否确认删除？')
      //   .then(function() {
      //     return delProject(ids)
      //   })
      //   .then(() => {
      //     this.getList()
      //     this.$modal.msgSuccess('删除成功')
      //   })
      //   .catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "tijianyuyue/project/export",
        {
          ...this.queryParams,
        },
        `project_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>

<style>
</style>
